// 用户班级表
module.exports = app=>{
    const {STRING,INTEGER,DATE} = app.Sequelize;
    const Userclass = app.model.define('userclass',{
        class_name:{
            type:STRING,
            comment:'所属班级'
        },
        user_name:{
            type:STRING,
            comment:'班主任'
        },
    })
    Userclass.associate = function () {
        // 所属项目关联
        app.model.Userclass.belongsTo(app.model.Class, {
          foreignKey: 'class_name',
          targetKey:'name',
          as:'class'
        })
        app.model.Userclass.belongsTo(app.model.User, {
          foreignKey: 'user_name',
          targetKey:'name',
          as:'user'
        })
    }
    return Userclass
}